import Vue from "vue";

import VueRouter from 'vue-router'

import Login from "@/views/Login"
import Index from "@/views/Index"


import Bingrenlist from "@/views/Mbingren/Bingrenlist" //我的病人

import Binglliindex from "@/views/Bingli/Binglliindex" // 电子病历首页
import Binglilist from "@/views/Bingli/Binglilist" //电子病历 列表
import Bingliadd from "@/views/Bingli/Bingliadd"// 添加 病历
import Bingliseenedit from "@/views/Bingli/Bingliseenedit" //查看和修改

import ZhuyuanguanliIndex from  "@/views/Zhuyuanguanli/ZhuyuanguanliIndex" //住院管理首页
import Guanlilist from "@/views/Zhuyuanguanli/Guanlilist" //住院管理列表
import AddGuanlibingren from "@/views/Zhuyuanguanli/AddGuanlibingren"//添加住院病人
import BaogaoIndex from "@/views/Baogaoquery/BaogaoIndex"//报告查询首页
import Baogaoquery from "@/views/Baogaoquery/BaogaoQuery"//报告查询
import Addbaogao from "@/views/Baogaoquery/addbaogao"//添加报告
import Baogaodit from "@/views/Baogaoquery/Baogaodit"//查看报告
import Outlist from "@/views/outguanli/Outlist"//出院管理
import Outindex from "@/views/outguanli/Outindex"//出院管理
import Outdayin from "@/views/outguanli/Outdayin"//出院打印
import Chufang from "@/views/chufangguanli/Chufang"//处方管理
import Jiuzhenzhixun from "@/views/zhixun/Jiuzhenzhixun"//就诊质讯
import Myapp from "@/views/myzhongxin/Myapp"//就诊质讯

Vue.use(VueRouter);

const router = new VueRouter({
    mode: 'history',
    routes: [
        {  //根目录
            path: "/",
            redirect: '/login'
        },
        { //登录
            path:"/login",
            name:"Login",
            component:Login
        },
        { // 首页
            path:"/index",//localhost:8080/index/binglliindex
            name:"Index",
            component:Index,
            redirect:'/index/bingrenlist',
            
            children:[
                { //我的病人
                    path:'bingrenlist',
                    name:"Bingrenlist",
                    component:Bingrenlist
                },
                { // 病历
                   path:'binglliindex',
                   name:"Binglliindex",

                   component:Binglliindex,

                   redirect:"/index/binglliindex/binglilist",

                   children:[
                       {  //电子病历列表
                           path:'binglilist',
                           name:'Binglilist',
                           component:Binglilist
                       },
                       { //添加病历
                         path:'bingliadd',
                         name:'Bingliadd',
                         component:Bingliadd
                       },
                       {// 查看和修改
                        path:'bingliseenedit',
                        name:'Bingliseenedit',
                        component:Bingliseenedit
                       }
                   ]
                },
                { //住院管理
                    path:'zhuyuanguanliIndex',
                    name:"ZhuyuanguanliIndex",
                    component:ZhuyuanguanliIndex,
                    // redirect:"/index/zhuyuanguanliIndex/guanlilist",
                    children:[
                          {// 住院管理；list
                            path:'guanlilist',
                            name:'Guanlilist',
                            component:Guanlilist
                           },
                          {// 添加住院病人
                            path:'addGuanlibingren',
                            name:'AddGuanlibingren',
                            component:AddGuanlibingren
                           }
                    ]
                },
                { //报告查询
                    path:'baogaoIndex',
                    name:"BaogaoIndex",
                    component:BaogaoIndex,
                    children:[
                          {// 报告查询；list
                            path:'baogaoquery',
                            name:'Baogaoquery',
                            component:Baogaoquery
                           },
                          {// 添加报告
                            path:'addbaogao',
                            name:'Addbaogao',
                            component:Addbaogao
                           },
                          {// 查看修改报告
                            path:'baogaodit',
                            name:'Baogaodit',
                            component:Baogaodit
                           }
                    ]
                },
                { //出院管理
                    path:'outindex',
                    name:"Outindex",
                    component:Outindex,
                    children:[
                          {// 出院管理打印
                            path:'outlist',
                            name:'Outlist',
                            component:Outlist
                           },
                          {// 出院管理打印
                            path:'outdayin',
                            name:'Outdayin',
                            component:Outdayin
                           },
                    ]
                },
                { //处方管理
                    path:'chufang',
                    name:"Chufang",
                    component:Chufang
                },
                { //就诊质讯
                    path:'jiuzhenzhixun',
                    name:"Jiuzhenzhixun",
                    component:Jiuzhenzhixun
                },
                { //个人中心
                    path:'myapp',
                    name:"Myapp",
                    component:Myapp
                },
            ]
        }
        
      
    ]
})
//路由守卫
// router.beforeEach((to, from, next) => {
//     console.log(to,from);

//     var getlogin =sessionStorage.getItem("login"); // 判断登录状态

//        if(to.name=='Login'){
//            next()

//        }else{ //其他页面
//           if(getlogin){
//                next()
//           }else{
//               next({path:'/login'})
//           }

//        }
// })
export default router;